/*
 * @author EX-XIEYUWEN001
 * Filename:    SummaryServiceImpl.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014年10月8日
 */
package com.paic.mhis.hcpms.quota.calculationreport.calculationdataItem.biz.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.paic.mhis.hcpms.quota.calculationreport.calculationdataItem.biz.service.SummaryService;
import com.paic.mhis.hcpms.quota.calculationreport.calculationdataItem.dto.CalculationResultDTO;
import com.paic.mhis.hcpms.quota.calculationreport.calculationdataItem.intergration.dao.SummaryDAO;
import com.paic.mhis.hcpms.quota.calculationreport.calculationjob.dto.HcpmsKpiJobParamDTO;
import com.paic.pafa.exceptions.BusinessException;

@Service("summaryService")
public class SummaryServiceImpl implements SummaryService {
	@Autowired
	private SummaryDAO summaryDao;

	private Map<String, Object> paramMap = new HashMap<String, Object>();

	/**
	 * 数据项汇总就诊信息-日
	 * 
	 * @param userName
	 *            当前汇总人
	 * @param batchNo
	 *            当前批次号
	 */
	@Transactional
	@Override
	public CalculationResultDTO saveSummaryVisitDay(String userName, String batchNo) {
		paramMap.put("userName", userName);
		paramMap.put("batchNo", batchNo);
		CalculationResultDTO paramDto = null;
		try {
			paramDto = new CalculationResultDTO();
			summaryDao.saveSummaryVisitDay(paramMap);
			paramDto.setIsError("N");
			paramDto.setMessage("数据项汇总就诊信息-日成功");
		} catch (BusinessException e) {
			paramDto.setIsError("Y");
			paramDto.setMessage(e.getMessage());
			// throw new FwaBusinessException(e.getMessage());
		}
		return paramDto;
	}

	/**
	 * 数据项汇总就诊信息-月
	 */
	@Transactional
	@Override
	public CalculationResultDTO saveSummaryVisitMonth(HcpmsKpiJobParamDTO dto) {
		paramMap.put("userName", dto.getUserId());
		paramMap.put("batchNo", dto.getBatchNo());
		paramMap.put("month", dto.getMonth());
		CalculationResultDTO paramDto = null;
		try {
			paramDto = new CalculationResultDTO();
			summaryDao.saveSummaryVisitMonth(paramMap);
			paramDto.setIsError("N");
			paramDto.setMessage("数据项汇总就诊信息-月成功");
		} catch (BusinessException e) {
			paramDto.setIsError("Y");
			paramDto.setMessage(e.getMessage());
		}
		return paramDto;
	}

	/**
	 * 数据项汇总单据信息-日
	 */
	@Transactional
	@Override
	public CalculationResultDTO saveSummaryBillDay(String userName, String batchNo) {
		paramMap.put("userName", userName);
		paramMap.put("batchNo", batchNo);
		CalculationResultDTO paramDto = null;
		try {
			paramDto = new CalculationResultDTO();
			summaryDao.saveSummaryBillDay(paramMap);
			paramDto.setIsError("N");
			paramDto.setMessage("数据项汇总单据信息-日成功");
		} catch (BusinessException e) {
			paramDto.setIsError("Y");
			paramDto.setMessage(e.getMessage());
		}
		return paramDto;
	}

	/**
	 * 数据项汇总单据信息-月
	 */
	@Transactional
	@Override
	public CalculationResultDTO saveSummaryBillMonth(HcpmsKpiJobParamDTO dto) {
		paramMap.put("userName", dto.getUserId());
		paramMap.put("batchNo", dto.getBatchNo());
		paramMap.put("month", dto.getMonth());
		CalculationResultDTO paramDto = null;
		try {
			paramDto = new CalculationResultDTO();
			summaryDao.saveSummaryBillMonth(paramMap);
			paramDto.setIsError("N");
			paramDto.setMessage("数据项汇总单据信息-月成功");
		} catch (BusinessException e) {
			paramDto.setIsError("Y");
			paramDto.setMessage(e.getMessage());
		}
		return paramDto;
	}

}
